<!DOCTYPE html>
<html lang="cmn-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>文档 - 禁用中</title>
    <link th:href="@{/frame/layui/css/layui.css}" rel="stylesheet">
</head>
<body>
<div class="layui-fluid">
    <table id="docneedchecktable" lay-filter="docneedchecktable"></table>
</div>
<script type="text/javascript" th:src="@{/frame/layui/layui.js}"></script>
<script id="showPreview" type="text/html">
    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="previewDoc">预览</a>
</script>
<script id="actions" type="text/html">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="nopass">解禁</a>
</script>
<script>
    layui.use(['table', 'layer'], function () {
        var table = layui.table;
        var $ = layui.$;
        table.render({
            // 绑定的table元素
            elem: '#docneedchecktable'
            // 开启右侧工具栏
            , toolbar: true
            // 异步数据接口
            , url: '[[@{/document/admin/getWithStatus}]]'
            // 访问方式
            , method: 'post'
            // 分页切换时显示加载层
            , loading: true
            // 分页请求参数名
            , request: {
                pageName: 'index',
                limitName: 'pageSize'
            }
            , where: {
                status: '禁用'
            }
            // 开启分页
            , page: true
            // 表格标题
            , title: '用户列表'
            , cols: [ [
                // {align: 'center', type: 'checkbox', fixed: 'left'},
                {width: 100, align: 'center', field: 'docid', title: '文档编号'},
                {width: 100, align: 'center', title: '分类', templet: "<div>{{d.docGroup.groupname}}</div>"},
                {width: 200, align: 'center', field: 'title', title: '标题'},
                {width: 200, align: 'center', field: 'storedname', title: '存储文件名'},
                {width: 80, align: 'center', title: '类型', templet: "<div>{{d.suffixicon.suffix}}</div>"},
                {width: 200, align: 'center', field: 'description', title: '简介'},
                {width: 80, align: 'center', field: 'pages', title: '页数'},
                {width: 150, align: 'center', title: '大小', templet: "<div>{{d.filesize}}字节</div>"},
                {width: 100, align: 'center', field: 'neededintegral', title: '所需积分'},
                {width: 80, align: 'center', field: 'hot', title: '热度'},
                {width: 200, align: 'center', title: '上传者', templet: "<div>{{d.uploaduser.phone}}</div>"},
                {
                    width: 200,
                    align: 'center',
                    field: 'uploadtime',
                    title: '上传时间',
                    templet: "<div>{{layui.util.toDateString(d.uploadtime, 'yyyy年MM月dd日 HH:mm:ss')}}</div>"
                },
                {width: 100, align: 'center', field: 'downloadtimes', title: '下载次数'},
                {width: 80, align: 'center', title: '预览', templet: '#showPreview'},
                {width: 150, align: 'center', title: '操作', templet: '#actions'}
            ] ]
        });

        // 行工具栏事件
        table.on('tool(docneedchecktable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'previewDoc':
                    layer.open({
                        type: 2
                        , title: '文档预览'
                        , maxmin: true
                        , content: '[[@{/document/admin/docPreviewPage}]]?docid=' + data.docid
                        , area: ['980px', '550px']
                        // ,success:function (layero,index) {
                        //     var iframe = window['layui-layer-iframe' + index];
                        //     iframe.deliverValue(other);
                        // }
                    });
                    break;
                case 'nopass':
                    $.post('[[@{/document/admin/changeDocStatus}]]', {docid: data.docid, status: '待审核'}, function () {
                        layer.msg('文档已经解禁！');
                        obj.del();
                    });
                    break;
            }
        });
    });
</script>
</body>
</html>